package com.gdpu.component;


import com.gdpu.service.PortalOmsOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import sun.net.www.MessageHeader;

import java.util.Date;

/**
 * @Author:weiming
 * @Date:2021/6/22
 * 取消订单消费者
 */
@Component
@EnableRabbit
public class CancelMessageReceiver {


    private static Logger LOGGER = LoggerFactory.getLogger(CancelMessageReceiver.class);

    @Autowired
    private PortalOmsOrderService omsOrderService;

    /**
     * 监听死信队列
     */
    @RabbitListener(queues = "#{deadQueue.name}")
    public void handleCancelOrder(Integer orderId){
        LOGGER.debug("process orderId:{}",orderId);
        // 取消超时订单
        omsOrderService.cancelTimeOutOrder(orderId);
        System.out.println("process orderId:" + orderId);
    }

}
